const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

/*
打开子页面
参数：url - 跳转地址
      param - 传递的参数 
*/
const openChild = param => {
    var name = param.currentTarget.dataset.url;
    var value = param.currentTarget.dataset.param;
    wx.navigateTo({
        url: "../" + name + "/" + name + "?" + value
    });
    this.setData({
        showBtn: false,
        showMenuBtn: false,
        idTouchMove: false,
        touchId: -1
    });
}

module.exports = {
  formatTime: formatTime,
  openChild: openChild
}
